import requests

def get_docker_image_size(repository, tag='latest'):
    url = f"http://registry.cn-hangzhou.aliyuncs.com/mytest_docker123/nginx:1.9.14"
    try:
        response = requests.get(url)
        response.raise_for_status()
        data = response.json()
        image_size = data.get('full_size', 0)
        return image_size
    except requests.RequestException as e:
        print(f"请求出错: {e}")
    except ValueError as e:
        print(f"解析 JSON 数据出错: {e}")
    return 0


if __name__ == "__main__":
    repository = "library/nginx"
    tag = "latest"
    size = get_docker_image_size(repository, tag)
    if size:
        print(f"镜像 {repository}:{tag} 的大小是 {size} 字节。")
    else:
        print("未能获取到镜像大小信息。")